/* JavaLog - package tracker 
* 
* Copyright (C) 2009 Allyson Lima, Diego Pedro, Victor Freire
* 
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software 
* Foundation, either version 3 of the License, or (at your option) any later version.
* 
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License along with this 
* program. If not, see <http://www.gnu.org/licenses/>.
*/

package br.edu.ufcg.ccc.javalog;

import java.util.Map;
import java.util.HashMap;

/**
 * Headquarters.
 * @author Allyson Lima, Diego Pedro, Victor Freire
 * @version 12/10/09
 */
public class Headquarters extends Franchise	{
	final Map<Address, Franchise> franchises = new HashMap<Address, Franchise>();
	
	public Headquarters(String name, Address address, boolean hasAirport) {
		super(name, address, hasAirport);
						
	}
	
	/**
	 * Searches and returns the most profitable franchise.
	 * @return most profitable franchise.
	 */
	public Franchise mostProfitableFranchise() {
		// TODO
		return null;
	}
	
	/**
	 * Returns the franchise that has handled the highest number of packages.
	 * @return most active franchise
	 */
	public Franchise mostActiveFranchise() {
		// TODO
		return null;
	}
	
	/**
	 * Creates a new franchise in the database.
	 * @return true if succeeded, false otherwise.
	 */
	public boolean addFranchise(Franchise f) {
		if(franchises.containsKey(f.getAddress())) return false;
		franchises.put(f.getAddress(), f);		
		return true;
	}
	
	/**
	 * Searches for the desired franchise.
	 * @param addr franchise location
	 * @return requested franchise
	 */
	public Franchise getFranchise(Address addr) {
		return franchises.get(addr);
	}
	
	/**
	 * Remove a franchise.
	 * @param addr the franchise location
	 * @return the removed Franchise or null if failed
	 */
	public Franchise removeFranchise(Address addr) {
		return franchises.remove(addr);
	}
}
